package com.tanggh.util;

import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import com.tanggh.entity.Lists;

public class XMLUtils{

	public static void toXML(Lists<?> list,Class<?> clazz,String path) throws JAXBException{
		toXML(list, clazz, path, "gbk");
	}
	
	public static void toXML(Lists<?> list,Class<?> clazz, String path,String encoding) throws JAXBException{
		File file = new File(path);
		JAXBContext jaxbContext = JAXBContext.newInstance(Lists.class,clazz);
		Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
		// output pretty printed
		jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		jaxbMarshaller.setProperty(Marshaller.JAXB_ENCODING, "gbk");
//		jaxbMarshaller.marshal(list, file);
		jaxbMarshaller.marshal(list, System.out);
	}
}
